<template>
    <view class="new">
        <view class="title">
            <view>
            <span>Hollow!</span>
            </view>
            <view>
                <span>请注册账号</span>
            </view>
        </view>
        <view class="form">
            <view class="form">
                <input class="uni-input" v-model=" username" type="text" placeholder="请输入用户名" />
                <input class="uni-input" v-model="password" password type="text" placeholder="请输入密码" />
            </view>
        </view>
        <view class="btn">
            <button @tap="addnew">立即注册</button>
            <view class="tip">
                <text type="primary" @click="addlogin">已有账号，前往登录</text>
            </view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                name: "", 
                username: "",
                 stuNo: "",
                stuClass: "", 
                password: ""
            }
        },
        methods: {
            addnew() {
               
                uniCloud.callFunction({
                    //函数名（接口名）
                    name: "Enroll-hotel",
                    data: {
                        username: this.username,
                        password: this.password,
                         name: this.name,
                        stuNo: this.stuNo,
                        stuClass: this.stuClass 
                    },
                    success: (res) => {
                        console.log(res);
                        if (res.result.code == 200) {
                            uni.showToast({
                                title: "注册成功",
                                icon: "none",
                                duration: 2000
                            })
                            setTimeout(() => {
                                uni.navigateTo({
                                    url: "/pages/Login-hotel/Login-hotel"
                                })
                            }, 2000)
 
                        }
                    }
                })
            },
            addlogin(){
                uni.navigateTo({
                    url: "/pages/Login-hotel/Login-hotel"
                })
            }
        }
    }
</script>

<style lang="scss">
    .new {
        padding: 100rpx 40rpx;
        background: url("../../static/down.png");
        background-size: 100% 100%;
        height: 100vh;

        .title {
            font-weight: bolder;
            font-size: 40rpx;
        }

        .form {
            margin-top: 100rpx;

            input {
                border-bottom: 1px solid #d6d6d6;
                margin-bottom: 40rpx;
            }
        }

        .btn {
            margin-top: 100rpx;

            button {
                background-color: #11d77e;
                color: white;
            }

            .tip {
                text-align: right;
                color: gray;
                margin-top: 20rpx;

            }
        }
    }
</style>
